/**
 * 动态职位数组
 * 添加的时候注意中英文数组对应顺序一致
 */
const zhJob = [
  {
    jobName: '个人助理',
    jobInfo: [
      {
        title: '岗位职责',
        options: [
          '1. 根据项目经理的要求，协助经理起草公司总结、计划、决议等公文函件；',
          '2. 根据经理的要求，负责各种会议记要、备忘录及其它文件的整理、打印、分发、归档、保管等工作；',
          '3. 负责处理好经理的日常工作安排，如会议、工作约会、宴请等；',
          '4. 协助经理落实公司各项任务进度并及时汇报；',
          '5. 完成经理交办的日常业务及行政事务工作。'
        ]
      },
      {
        title: '任职要求',
        options: [
          '1. 行政管理相关专业本科以上学历；',
          '2. 工作有条理、具有逻辑性，能合理安排重要紧急事项；',
          '3. 具备良好的文字功底，能撰写或校对重要文字资料；',
          '4. 具备良好的职业素养和职业操守；',
          '5. 良好的人际关系处理能力及良好的理解能力；',
          '6. 精通Office软件，包括excel和Word；',
          '7. 精通中文申请者优先。'
        ]
      },
      {
        title: '薪资范围',
        options: [
          'SGD2,400 - SGD2,800 (根据工作经验) '
        ]
      }
    ]
  },
  {
    jobName: '财务会计主管',
    jobInfo: [
      {
        title: '岗位职责',
        options: [
          '1. 负责公司全盘帐务处理，包括原始单据及会计凭证记录、账簿登记，及时出具报表；',
          '2. 负责常规税务工作，包括定期开具和验证专用发票、税金计算、纳税申报、增值税进项认证、所得税汇算清缴等；',
          '3. 协助内部和外部审计工作的进行；',
          '4. 通过与业务人员及相关政府机关及时有效沟通，确保良好的合作关系；',
          '5. 根据该职位提出合理的财务规划和财务建议；',
          '6. 协助其他相关财务工作。'
        ]
      },
      {
        title: '任职要求',
        options: [
          '1. 最低学历要求：会计、财务、商业或其他同等学历的学位/文凭;',
          '2. 熟练应用财务及Office办公软件，Excel表单制作达到精通程度；',
          '3. 有代理记账行业优先；',
          '4. 具有3年以上相关经验优先；',
          '5. 熟悉报税系统和财税系统，熟悉税收法规；',
          '6. 思路清晰，条理性强，有良好的职业操守；',
          '7. 良好的沟通能力，主动学习能力及责任心；',
          '8. 精通中文者优先。'
        ]
      },
      {
        title: '薪资范围',
        options: [
          'SGD3,000 – SGD3,500 (根据工作经验) '
        ]
      }
    ]
  },
  {
    jobName: '行政人事主管',
    jobInfo: [
      {
        title: '岗位职责',
        options: [
          '人事方面：',
          '1. 所在分公司的人员招聘工作，能独立完成招聘工作，甄选行业优秀人才；',
          '2. 负责员工入职培训、在职培训组织，协助管理层进行员工考核；',
          '3. 考勤管理、社保公积金交纳与办理、员工入离职手续办理等；',
          '4. 负责月度HR相关各类报表（薪酬、绩效）的统计、报备；',
          '5. 协助领导开展事务性工作。',
          '行政方面：',
          '1. 负责公司行政后勤类相关工作；',
          '2. 执行团建活动、节庆活动，年会等；',
          '3. 收发快递、绿植管理、办公用品、固定资产管理；',
          '4. 会议纪要的记录；',
          '5. 物业对接，办理公司日常行政费用交纳；',
          '6. 完成上级交办的其它临时性工作。'
        ]
      },
      {
        title: '任职要求',
        options: [
          '1. 最低学历要求：人力资源/商业或其他同等学历的学位/文凭；',
          '2. 两年以上的人事行政相关工作经验；',
          '3. 做事细致，善于思考与总结，拥有良好的组织协调能力，逻辑力好，自驱力强；',
          '4. 精通Office软件，包括excel和Word；',
          '5. 精通普通话优先；',
          '6. 出色的沟通与人际交往能力。',
        ]
      },
      {
        title: '薪资范围',
        options: [
          'SGD3,000 – SGD3,500 (根据工作经验) '
        ]
      }
    ]
  },
  {
    jobName: '私人司机',
    jobInfo: [
      {
        title: '岗位职责',
        options: [
          '1. 负责总经理日常专车专职司机服务；',
          '2. 负责保持车辆的干净，整洁；',
          '3. 负责办理车辆的年审、维护与保养，定期检查车况，保证行车安全；',
          '4. 遵守交通规则，无不良违法记录；',
          '5. 协助其他临时指派的工作；',
          '6. 服从总经理安排，不擅离职守，不私自开车外出。'
        ]
      },
      {
        title: '任职要求',
        options: [
          '1. 退伍军人优先；',
          '2. 精通中文者优先；',
          '3. 与所有乘客保持礼貌和专业的风度；',
          '4. 30-45岁，有5年以上驾龄，长途驾驶经验丰富者优先；',
          '5. 熟悉新加坡路况，在新加坡担任过商务司机，熟练驾驶各种商务轿车；',
          '6. 至少取得驾驶证（Class 3）5年以上，实际驾驶车辆三年以上并无重大交通事故并提供相关证明；',
          '7. 能适应并执行对于工作的加班、市内其他区域支援、出差等突发安排；',
          '8. 有责任心，守时。性格稳重，头脑灵活，理解能力强，好沟通，做事积极主动，保密意识强；',
          '9. 有总经理司机相关工作经验优先。'
        ]
      },
      {
        title: '薪资范围',
        options: [
          'SGD2,600 – SGD3,500 (根据工作经验) '
        ]
      }
    ]
  }
];

const enJob = [
  {
    jobName: 'PERSONAL ASSISTANT',
    jobInfo: [
      {
        title: 'Job Responsibilities',
        options: [
          '1. Assist the manager in drafting company summaries, plans, resolutions, and other official documents according to the project manager’s requirements.',
          '2. Responsible for sorting, printing, distributing, filling, and keeping of various meeting notes, memoranda, and other documents according to the manager’s requirements.',
          '3. Responsible for managing the manager’s daily work arrangements, such as meetings, appointments, events, etc.',
          '4. Assist the manager in implementing the progress of various company tasks and report in a timely manner.',
          '5. Complete daily tasks that are assigned by a superior.',
        ]
      },
      {
        title: 'Job Requirements',
        options: [
          '1. Degree/Diploma in major of administrative or other equivalent.',
          '2. Good work order, logical thinking, can arrange important and urgent matters reasonably. ',
          '3. Good writing skills and able to proofread important documents. ',
          '4. Strong attention to detail, organizational skills, and professional ethics.',
          '5. Excellent communication, interpersonal skills, and good understanding skills. ',
          '6. Proficient in Microsoft Office, including Excel and Word. ',
          '7. Proficient in Mandarin is preferred.'
        ]
      },
      {
        title: 'Salary Range',
        options: [
          'SGD2,400 – SGD2,800 (Based on working experience) '
        ]
      }
    ]
  },
  {
    jobName: 'ACCOUNT EXECUTIVE',
    jobInfo: [
      {
        title: 'Job Responsibilities',
        options: [
          '1. Responsible for the full spectrum of accounting including tax invoice, payment voucher, account book registration, timely issuance of reports. ',
          '2. Responsible for day to day tax work, including regular issuance and verification of tax calculation, tax declaration, VAT input certification, income tax settlement, etc.',
          '3. Assist in internal and external audit work. ',
          '4. Ensure a good cooperative relationship through timely and effective communication with business personnel and relevant government departments. ',
          '5. Responsible for financial planning and financial advice. ',
          '6. Assist in other tasks that are related to finance. ',
          '7. To handle other ad hoc tasks assigned by superiors. '
        ]
      },
      {
        title: 'Job Requirements',
        options: [
          '1. Minimum Degree/Diploma in Accounting, Finance, Business or its other equivalent. ',
          '2. Proficient in Microsoft Office, including Excel and Word. ',
          '3. Experience in a bookkeeping agency is preferred. ',
          '4. Minimum 3 years of relevant experience is preferred. ',
          '5. Familiar with tax reporting and financial systems and have knowledge of tax law and regulations. ',
          '6. Strong attention to detail, organizational skills, and professional ethics.',
          '7. Excellent communication and interpersonal skills.',
          '8. Proficient in Mandarin is preferred.'
        ]
      },
      {
        title: 'Salary Range',
        options: [
          'SGD3,000 – SGD3,500 (Based on working experience) '
        ]
      }
    ]
  },
  {
    jobName: 'HUMAN RESOURCES CUM ADMIN EXECUTIVE',
    jobInfo: [
      {
        title: 'Job Responsibilities',
        options: [
          'Human Resources: ',
          '1. To provide support and input to the recruitment cycle, including processing applications, assessment and selection, and the onboarding and induction of new staff. ',
          '2. Responsible for recruitment administration, including screening applications and assisting with the organizing of interviews, and liaising with candidates. ',
          '3. Responsible for attendance management and maintaining a smooth offboarding process.',
          '4. Responsible for monthly statistics and reporting of various HR-related reports, etc: compensation and performance KPI).  ',
          '5. To handle other ad hoc tasks assigned by superiors. ',
          'Administration:  ',
          '1. Responsible for company administration work. ',
          '2. Organize team building activities, festivals, and annual dinner, etc. ',
          '3. Responsible for receiving and sending parcel delivery, plant management, office supplies and company asset management. ',
          '4. Record meeting minutes. ',
          '5. Liaise with property management and handle daily administrative expenses. ',
          '6. To handle other ad hoc tasks assigned by superiors. ',
        ]
      },
      {
        title: 'Job Requirements',
        options: [
          '1. Minimum Degree/Diploma in Human Resources/Business or its other equivalent.',
          '2. Minimum 2 years’ experience in human resources and administration. ',
          '3. Strong attention to detail, organizational skills, and professional ethics.',
          '4. Proficient in Microsoft Office, including Excel and Word. ',
          '5. Proficiency in Mandarin is preferred.',
          '6. Excellent communication and interpersonal skills.'
        ]
      },
      {
        title: 'Salary Range',
        options: [
          'SGD3,000 – SGD3,500 (Based on working experience) '
        ]
      }
    ]
  },
  {
    jobName: 'PERSONAL DRIVER',
    jobInfo: [
      {
        title: 'Job Responsibilities',
        options: [
          '1. Responsible for providing dedicated driving services to the General Manager on a daily basis. ',
          '2. Maintaining a clean and well-maintained vehicle.',
          '3. Keeping track of vehicle maintenance and service schedules.',
          '4. Adhering to all traffic rules and regulations and clean driving records. ',
          '5. Assisting with any additional tasks as assigned.',
          '6. Follow the instructions of the General Manager, do not leave your post without permission and do not drive the car out without getting authorization. ',
        ]
      },
      {
        title: 'Job Requirements',
        options: [
          '1. Retired army are preferred. ',
          '2. Able to communicate in Chinese and English. ',
          '3. Maintaining a courteous and professional demeanor with all passengers.',
          '4. Age between 30-45 years old, with more than 5 years of driving experience and with long-distance driving experience are preferred. ',
          '5. Familiar with Singapore roads, have experience as a driver in Singapore and able to drive in 7 seaters or luxurious vehicles. ',
          '6. Valid driving license (class 3 or above) for at least 5 years with at least practical driving experience without any major traffic accidents (proof of no major traffic accidents.',
          '7. Able to adapt and carry out emergency arrangements for work, including overtime, travel for business trips.',
          '8. Responsibility, pleasant personality, punctual, honest, strong comprehension skills, good communication skills, proactive at work and keeping all information confidentially.  ',
          '9. Experienced in Personal Driver is preferred.'
        ]
      },
      {
        title: 'Salary Range',
        options: [
          'SGD2,600 – SGD3,500 (Based on working experience) '
        ]
      }
    ]
  }
];

let isShowModal = false;
const jobContainer = document.getElementById('jobContainer');
const jobModal = document.getElementById('jobModal');
addJob();

jobModal.addEventListener('click', () => {
  handleClickShowModal(false)
})

/**
 * 添加职位页面结构
 */
function addJob() {
  let currJobList = language === 'zh' ? zhJob : enJob;
  let jobStr = ''
  for (let i = 0; i < currJobList.length; i++) {
    const currItem = currJobList[i];
    let jobInfoStr = '';
    for (let j = 0; j < currItem.jobInfo.length; j++) {
      const currChildItem = currItem.jobInfo[j];
      let jobOptionStr = '';
      jobInfoStr += `<div class="ha-job-content-title">${currChildItem.title}</div>`

      for (let k = 0; k < currChildItem.options.length; k++) {
        jobOptionStr += `<div>${currChildItem.options[k]}</div>`
      }
      jobInfoStr += jobOptionStr;
    }
    jobStr += `
      <div class="ha-job-item" curr-attr="${currItem.jobName}">
        <div class="ha-flex-center-between">
          <span class="ha-job-item-title">${currItem.jobName}</span>
          <div class="ha-flex-center-between">
            <button class="ha-job-item-btn" lang-attr="offers2" onclick="handleClickShowModal()">${language === 'zh' ? '立即申请' : 'Apply Immediately'}</button>
            <img class="ha-job-down" click-attr="${currItem.jobName}" onclick="handleClickDown(this)" src="/images/job_offers/arrow_down.png">
            <img class="ha-job-up" click-attr="${currItem.jobName}" onclick="handleClickUp(this)" src="/images/job_offers/arrow_up.png">
          </div>
        </div>
        <div class="ha-job-content">
          ${jobInfoStr}
        </div>
      </div>
    `
  }
  jobContainer.innerHTML = jobStr;
}

function handleClickDown(ele) {
  const attValue = ele.getAttribute('click-attr');
  const currEle = document.querySelector(`[curr-attr="${attValue}"]`);
  currEle.classList.add('active');
}

function handleClickUp(ele) {
  const attValue = ele.getAttribute('click-attr');
  const currEle = document.querySelector(`[curr-attr="${attValue}"]`);
  currEle.classList.remove('active');
}

function handleClickShowModal(flag) {
  if (flag !== undefined) {
    isShowModal = flag;
  } else {
    isShowModal = !isShowModal;
  }
  if (isShowModal) {
    jobModal.classList.add('ha-modal-show');
  } else {
    jobModal.classList.remove('ha-modal-show');
  }
}

window.addEventListener('setItemEvent', () => {
  setTimeout(() => {
    addJob();
  }, 300)
});
